LinearInterpIntFloat Function

private function LinearInterpIntFloat(x1, x2, y1, y2, x) result(y)

calculates linear interpolation between integer numbers with output real.

Arguments

Type IntentOptional Attributes Name
integer, intent(in) :: x1
integer, intent(in) :: x2
real(kind=float), intent(in) :: y1
real(kind=float), intent(in) :: y2
integer, intent(in) :: x

Return Value real(kind=float)


Source Code

FUNCTION LinearInterpIntFloat  &
  ( x1, x2, y1, y2, x )     &
RESULT (y)

IMPLICIT NONE

! Function arguments
! Scalar arguments with intent(in):
INTEGER, INTENT (IN) :: x1, x2, x
REAL (KIND = float), INTENT (IN) :: y1, y2

! Scalar arguments with intent (out):
REAL (KIND = float) :: y

!------------end of declaration------------------------------------------------

y = y1 + ( y2 - y1 ) / ( x2 - x1 ) * ( x - x1 )

END FUNCTION LinearInterpIntFloat